package com.insuremonitor.system.service.impl;

import com.insuremonitor.common.core.domain.AjaxResult;
import com.insuremonitor.common.utils.DateUtils;
import com.insuremonitor.system.domain.FrontInsureRateExtend;
import com.insuremonitor.system.mapper.FrontInsureRateExtendMapper;
import com.insuremonitor.system.service.IFrontInsureRateExtendService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 货物类型与费率的关系Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-11-21
 */
@Service
public class FrontInsureRateExtendServiceImpl implements IFrontInsureRateExtendService 
{
    @Autowired
    private FrontInsureRateExtendMapper frontInsureRateExtendMapper;

    /**
     * 查询货物类型与费率的关系
     * 
     * @param insureExtendId 货物类型与费率的关系主键
     * @return 货物类型与费率的关系
     */
    @Override
    public FrontInsureRateExtend selectFrontInsureRateExtendByInsureExtendId(Long insureExtendId)
    {
        return frontInsureRateExtendMapper.selectFrontInsureRateExtendByInsureExtendId(insureExtendId);
    }

    /**
     * 查询货物类型与费率的关系列表
     * 
     * @param frontInsureRateExtend 货物类型与费率的关系
     * @return 货物类型与费率的关系
     */
    @Override
    public List<FrontInsureRateExtend> selectFrontInsureRateExtendList(FrontInsureRateExtend frontInsureRateExtend)
    {
        frontInsureRateExtend.setStatus("1");
        return frontInsureRateExtendMapper.selectFrontInsureRateExtendList(frontInsureRateExtend);
    }

    /**
     * 新增货物类型与费率的关系
     * 
     * @param frontInsureRateExtend 货物类型与费率的关系
     * @return 结果
     */
    @Override
    public AjaxResult insertFrontInsureRateExtend(FrontInsureRateExtend frontInsureRateExtend)
    {
        frontInsureRateExtend.setCreateTime(DateUtils.getNowDate());
        int i =  frontInsureRateExtendMapper.insertFrontInsureRateExtend(frontInsureRateExtend);
        if(i>0){
            return AjaxResult.success("操作成功",frontInsureRateExtend.getInsureExtendId());
        }else {
            return AjaxResult.error("操作失败");
        }
    }

    /**
     * 修改货物类型与费率的关系
     * 
     * @param frontInsureRateExtend 货物类型与费率的关系
     * @return 结果
     */
    @Override
    public int updateFrontInsureRateExtend(FrontInsureRateExtend frontInsureRateExtend)
    {
        frontInsureRateExtend.setUpdateTime(DateUtils.getNowDate());
        return frontInsureRateExtendMapper.updateFrontInsureRateExtend(frontInsureRateExtend);
    }

    /**
     * 批量删除货物类型与费率的关系
     * 
     * @param insureExtendIds 需要删除的货物类型与费率的关系主键
     * @return 结果
     */
    @Override
    public int deleteFrontInsureRateExtendByInsureExtendIds(Long[] insureExtendIds)
    {
        return frontInsureRateExtendMapper.deleteFrontInsureRateExtendByInsureExtendIds(insureExtendIds);
    }

    /**
     * 删除货物类型与费率的关系信息
     * 
     * @param insureExtendId 货物类型与费率的关系主键
     * @return 结果
     */
    @Override
    public int deleteFrontInsureRateExtendByInsureExtendId(Long insureExtendId)
    {
        return frontInsureRateExtendMapper.deleteFrontInsureRateExtendByInsureExtendId(insureExtendId);
    }
}
